import { Controller, Post, Body, Req } from '@nestjs/common';
import { VisitLogService } from './log.service';

import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { addVisitLogPostDto, visitLogPostDto, visitLogDto } from './dto/create-post.dot';
import { Request } from 'express';

@ApiTags("访问日志")
@Controller('visit_log')
export class visitLogController {
  constructor(private readonly visitLog: VisitLogService) {}

  // 添加访问c
  @ApiOperation({ summary: '添加访问' })
  @Post('addVisitLog')
  add(@Body() body: addVisitLogPostDto, @Req() request: Request): Promise<visitLogDto> {
    return this.visitLog.addVisitLog(body, request);
  }
  
  // 获取列表
  @ApiOperation({ summary: '获取列表' })
  @Post('logList')
  list(@Body() body: visitLogPostDto): Promise<visitLogDto> {
    return this.visitLog.logList(body);
  }
}
